﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 计科2111林开心06
{
    public partial class _3_3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            StruInfoDataContext stu = new StruInfoDataContext();
            var s = from r in stu.Studnet
                    where r.name.Contains(TextBox2.Text)
                    select r;
            GridView1.DataSource = s;
            GridView1.DataBind();
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            StruInfoDataContext stu = new StruInfoDataContext();

            var s = from r in stu.Studnet
                    where r.name==TextBox3.Text
                    select r;
            stu.Studnet.DeleteAllOnSubmit(s);
            stu.SubmitChanges();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            StruInfoDataContext stu = new StruInfoDataContext();
            Studnet s = new Studnet();
            s.id = TextBox7.Text;
            s.name = TextBox5.Text;
            s.cid ="1";
            
            stu.Studnet.InsertOnSubmit(s);
            stu.SubmitChanges();
            var res = from r in stu.Studnet
                      select r;
            GridView1.DataSource = res;
            GridView1.DataBind();

        }
    }
}